﻿namespace Practices.SharePoint.Identity {
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Administration;
    using Microsoft.SharePoint.Administration.Claims;
    using Microsoft.SharePoint.Diagnostics;
    using Microsoft.SharePoint.WebControls;

    /// <summary>
    /// <see cref="http://msdn.microsoft.com/en-us/library/ee537299.aspx"/>
    /// </summary>
    public class ContosoClaimProvider : SPClaimProvider {
        /// <summary>
        ///     The following Name property is a required property.
        ///     The name should be unique across the farm.
        /// </summary>
        public override string Name {
            get {
                return "Contoso Claim Provider";
            }
        }

        public ContosoClaimProvider(string displayName) 
            : base(displayName) {         
        }

        #region Claims Picker
        //  Claims can be displayed in the People Picker control through claims picking. 
        //  The following methods in the SPClaimProvider class are required methods 
        //  if you want to implement claim picking in the People Picker control.

        protected override void FillSchema(SPProviderSchema schema) {
            throw new NotImplementedException();
        }

        protected override void FillClaimTypes(List<string> claimTypes) {
            throw new ArgumentNullException("claimValueTypes");
        }

        protected override void FillClaimValueTypes(List<string> claimValueTypes) {
            throw new ArgumentNullException("claimValueTypes");
        }

        protected override void FillEntityTypes(List<string> entityTypes) {
            throw new NotImplementedException();
        }

        #endregion

        #region Claims Augmentation
        //  When you include additional claims in a user's security token, you are augmenting claims. 
        //  If you want to augment claims, you must implement the following methods in the SPClaimProvider class.

        public override bool SupportsEntityInformation {
            get {
                return true;
            }
        }

        protected override void FillClaimsForEntity(Uri context, SPClaim entity, List<SPClaim> claims) {
            throw new NotImplementedException();
        }

        #endregion

        #region Displaying Hierarchy on the Left Pane of the Claims Picker
        //  If you want to display hierarchy on the left pane of the claims picker, 
        //  you must implement the following methods in the SPClaimProvider class.

        public override bool SupportsHierarchy {
            get {
                return false;
            }
        }

        protected override void FillHierarchy(Uri context, string[] entityTypes, string hierarchyNodeID, int numberOfLevels, SPProviderHierarchyTree hierarchy) {
            throw new NotImplementedException();
        }

        #endregion

        #region Resolving Claims in the Type-in Control of the Claims Picker
        //  If you want to be able to resolve claims by using the type-in control of the claims picker, 
        //  you must implement the following methods in the SPClaimProvider class.

        public override bool SupportsResolve {
            get {
                return false;
            }
        }

        protected override void FillResolve(Uri context, string[] entityTypes, SPClaim resolveInput, List<PickerEntity> resolved) {
            throw new NotImplementedException();
        }

        protected override void FillResolve(Uri context, string[] entityTypes, string resolveInput, List<PickerEntity> resolved) {
            throw new NotImplementedException();
        }

        #endregion

        #region Searching for Claims in the Claims Picker
        //  If you want to be able to search for claims in the claims picker, 
        //  you must implement the following property and method in the SPClaimProvider class.

        public override bool SupportsSearch {
            get {
                false;
            }
        }

        protected override void FillSearch(Uri context, string[] entityTypes, string searchPattern, string hierarchyNodeID, int maxCount, SPProviderHierarchyTree searchTree) {
            throw new NotImplementedException();
        }

        #endregion            
    }
}
